/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package cl.darksigns.webstat.client.delegate;

import cl.darksigns.webstat.back.ejb.GetClientMessageRemote;
import cl.darksigns.webstat.back.exception.WebStatException;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;
import org.apache.log4j.Logger;

import java.util.ResourceBundle;

/**
 *
 * @author _ViKtOr
 */
public class WebStatDelegate {
    
    Logger logger = Logger.getLogger(WebStatDelegate.class);
    GetClientMessageRemote remote = null;
    ResourceBundle res = ResourceBundle.getBundle("wst_client");
    private GetClientMessageRemote lookupGetClientMessageBean() {
        try {
            Context c = new InitialContext();
            logger.info("looking for: GetClientMessageBean");
            return (GetClientMessageRemote) c.lookup("java:comp/env/GetClientMessageBean");
        } catch (NamingException ne) {
           logger.error("NamingException: "+ ne.getMessage());
            throw new RuntimeException(ne);
        }
    }
    public WebStatDelegate(){
        remote = lookupGetClientMessageBean();
    }
    public String receiveMessage(String xml){
        return remote.receiveMessage(xml);
    }
     public String receiveSpecificMessage(String xml) throws WebStatException {
         return remote.receiveSpecificMessage(xml);
     }
  
}
